package com.wlhse.controller;

import com.wlhse.entity.EventRecordPojo;
import com.wlhse.service.EventRecordService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("EventRecordController")
@RequestMapping("/api/v1")
//事件
public class EventRecordController {

    @Resource
    private EventRecordService eventRecordService;

    @RequestMapping(value = "/event_record/{id}", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public String updateStudyCase(@RequestBody(required = false) EventRecordPojo eventRecordPojo, @PathVariable("id") int id) {
            eventRecordPojo.setId(id);
            return eventRecordService.updateEventRecord(eventRecordPojo);
    }

    @RequestMapping(value = "/event_record/{id}", method = RequestMethod.DELETE, produces = "application/json; charset=utf-8")
    public String deleteStudyCase(@PathVariable("id") int id) {
            return eventRecordService.deleteEventRecord(id);

    }

    @RequestMapping(value = "/event_record", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public String addStudyCase(@RequestBody(required = false) EventRecordPojo eventRecordPojo) {
            return eventRecordService.addEventRecord(eventRecordPojo);
    }

    @RequestMapping(value = "/event_record", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String selectAllStudyCase(@ModelAttribute EventRecordPojo eventRecordPojo) {
            return eventRecordService.queryEventRecord(eventRecordPojo);
    }

    @RequestMapping(value = "/event_record/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String selectSingleProblemImportDto(@PathVariable("id") int id) {
            return eventRecordService.queryEventRecordById(id);
    }
}
